package com.coollang.smartbra.activity;

import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Environment;
import android.provider.MediaStore;
import android.support.v4.content.ContextCompat;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.coollang.smartbra.MyAutoLayoutActivity;
import com.coollang.smartbra.R;
import com.coollang.smartbra.base.MyApplication;
import com.coollang.smartbra.choosephoto.CropImageActivity;
import com.coollang.smartbra.choosephoto.DealPictureUtils;
import com.coollang.smartbra.choosephoto.ImageChooseActivity_new;
import com.coollang.smartbra.choosephoto.IntentConstants;
import com.coollang.smartbra.constant.Constants;
import com.coollang.smartbra.eventbus.CommonEvent;
import com.coollang.smartbra.model.LogInDataBean;
import com.coollang.smartbra.presenter.SelfInfoPresenter;
import com.coollang.smartbra.utils.ActivitySwitcher;
import com.coollang.smartbra.utils.ImageLoader;
import com.coollang.smartbra.utils.LogUtils;
import com.coollang.smartbra.utils.TimeUtils;
import com.coollang.smartbra.utils.ToastUtils;
import com.coollang.smartbra.utils.TranslucentSystemBarUtils;
import com.coollang.smartbra.views.BaseLineView;
import com.coollang.smartbra.views.CloseUtils;
import com.facebook.drawee.view.SimpleDraweeView;
import com.google.gson.Gson;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cn.jeesoft.widget.pickerview.LoopListener;
import cn.jeesoft.widget.pickerview.LoopView;
import de.greenrobot.event.EventBus;
import io.realm.Realm;

import static com.coollang.smartbra.R.id.blv_weight_person;


/**
 * 编辑资料页面
 */
public class SelfInfoActivity extends MyAutoLayoutActivity {
    @BindView(R.id.status_bar)
    View statusBar;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.iv_right)
    ImageView ivRight;
    @BindView(R.id.content)
    RelativeLayout content;
    @BindView(R.id.iv_userhead)
    SimpleDraweeView ivUserhead;
    @BindView(R.id.rl_edithead)
    RelativeLayout rlEdithead;
    @BindView(R.id.blv_name_person)
    BaseLineView blvNamePerson;
    @BindView(R.id.blv_sex_person)
    BaseLineView blvSexPerson;
    @BindView(R.id.blv_age_person)
    BaseLineView blvAgePerson;
    @BindView(R.id.blv_height_person)
    BaseLineView blvHeightPerson;
    @BindView(R.id.blv_weight_person)
    BaseLineView blvWeightPerson;
    @BindView(R.id.tv_pick_cancel)
    TextView tvPickCancel;
    @BindView(R.id.tv_pick_confirm)
    TextView tvPickConfirm;
    @BindView(R.id.picklerview)
    LoopView picklerview;
    @BindView(R.id.tv_bmp_unit)
    TextView tvBmpUnit;
    @BindView(R.id.ll_loopview)
    LinearLayout llLoopview;
    @BindView(R.id.picture)
    TextView picture;
    @BindView(R.id.camera)
    TextView camera;
    @BindView(R.id.select_picture_cancel)
    TextView selectPictureCancel;
    @BindView(R.id.ll_picture)
    LinearLayout llPicture;
    @BindView(R.id.tv_birthday_cancel)
    TextView tvBirthdayCancel;
    @BindView(R.id.tv_birthday_confirm)
    TextView tvBirthdayConfirm;
    @BindView(R.id.pv_year)
    LoopView pvYear;
    @BindView(R.id.pv_month)
    LoopView pvMonth;
    @BindView(R.id.pv_day)
    LoopView pvDay;
    @BindView(R.id.ll_birthday)
    LinearLayout llBirthday;
    @BindView(R.id.rl_wh)
    RelativeLayout rlWh;
    @BindView(R.id.ll_sex)
    LinearLayout llSex;

    private static final int REQUEST_IMAGE = 0;
    private static final int CAMERA = 1;
    private static final int PICTURE = 2;
    private static final int CROPIMAGE = 3;
    private static final String CAMERA_IMAGE = "zhinengneiyi.jpg";
    private Bitmap photoBitmap;
    private static int TYPE_SEX = 1;
    private static int TYPE_HEIGHT = 2;
    private static int TYPE_WEIGHT = 3;
    private int startNub;
    private int endNub;
    private List<String> dataList = new ArrayList<>();
    private int firstIndex = -1;
    private String originalData;
    private int currentType;

    /**
     * 选中的年的下标
     */
    private int indexYear = -1;
    private int indexMonth = -1;
    private int indexDay = -1;
    private int currentYear;
    private int currentMonth;
    private int currentDay;
    private List<String> yearList;
    private List<String> monthList;
    private List<String> dayList;
    private String year = "1998";
    private String month = "12";
    private String day = "22";
    private String username;
    private String birth;
    private String height;
    private String weight;
    private static String TAG = "SelfInfoActivity";
    Gson gson;
    private SelfInfoPresenter mSelfInfoPresenter;


    @Override
    protected void initView() {
        setContentView(R.layout.activity_self_info);
        ButterKnife.bind(this);
        EventBus.getDefault().register(this);
        TranslucentSystemBarUtils.showChenJinZhuangTaiLan(statusBar, this, content);
        gson = new Gson();
        initViews();

        //获取今天时间,格式化
        String today = TimeUtils.getTodayYYYYMMDD();
        String time[] = today.split("-");
        currentYear = Integer.parseInt(time[0]);
        currentMonth = Integer.parseInt(time[1]);
        currentDay = Integer.parseInt(time[2]);
    }

    @Override
    protected void onDestroy() {
        EventBus.getDefault().unregister(this);
        super.onDestroy();
    }

    public void onEventMainThread(CommonEvent event) {
        if (event.type == CommonEvent.EDITNAME) {
            switch (event.what) {
                case CommonEvent.REQUESTSUEECCD:
                    username = event.msg;
                    blvNamePerson.setRightText(username);
                    MyApplication.mLogInDataBean.setNickname(username);
                    mSelfInfoPresenter.setRequestInfo();
                    break;
                default:
                    break;
            }
        }
    }

    private void setUserInfo() {
        LogInDataBean mLogInDataBean = MyApplication.mLogInDataBean;

        String avatar = mLogInDataBean.getAvatar();

        ImageLoader.loadNetImageAsCircle(avatar, ivUserhead);

        String nickname = mLogInDataBean.getNickname();
        if (!"".equals(nickname)) {
            blvNamePerson.setRightText(nickname);
        } else {
            blvNamePerson.setRightText(getString(R.string.please_edit));
        }

        // 性别
        String gender = mLogInDataBean.getGender();
        if (Integer.parseInt(gender) == 0) {
            blvSexPerson.setRightText("女");
        } else {
            blvSexPerson.setRightText("男");
        }

        // 生日

        String birth = mLogInDataBean.getBirth();
        String birthDay = TimeUtils.unixTimeToBeijingDate(Long.parseLong(birth));
        blvAgePerson.setRightText(birthDay);

        // 体重
        blvWeightPerson.setRightText(mLogInDataBean.getWeight() + getString(R.string.unit_kg));

        // 身高
        blvHeightPerson.setRightText(mLogInDataBean.getHeight() + getString(R.string.unit_cm));
    }

    private void initViews() {
        ivRight.setVisibility(View.GONE);
        tvTitle.setText(getString(R.string.edit_personinfo));
        tvTitle.setTextColor(ContextCompat.getColor(this, R.color.black_80));

        blvNamePerson.setRightText(getString(R.string.please_edit));
        blvSexPerson.setRightText(getString(R.string.please_edit));
        blvAgePerson.setRightText(getString(R.string.please_edit));
        blvHeightPerson.setRightText(getString(R.string.please_edit));
        blvWeightPerson.setRightText(getString(R.string.please_edit));
    }

    @Override
    protected void initData() {

        // 设置用户信息
        setUserInfo();
        mSelfInfoPresenter = new SelfInfoPresenter(this);
    }

    @OnClick({R.id.tv_birthday_cancel, R.id.tv_birthday_confirm, R.id.tv_pick_cancel,
            R.id.tv_pick_confirm, R.id.picture, R.id.camera, R.id.select_picture_cancel,
            R.id.rl_edithead, R.id.blv_name_person, R.id.blv_sex_person, R.id.blv_age_person,
            R.id.blv_height_person, blv_weight_person, R.id.iv_back})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.tv_birthday_cancel:
                llBirthday.setVisibility(View.GONE);
                break;
            case R.id.tv_birthday_confirm:
                if (!yearList.get(pvYear.getCurrentItem()).equals(year)) {
                    year = yearList.get(pvYear.getCurrentItem());
                    onYearChanged(year);
                }
                if (!monthList.get(pvMonth.getCurrentItem()).equals(month)) {
                    month = monthList.get(pvMonth.getCurrentItem());
                    onMonthChanged(month);
                }
                if (!dayList.get(pvDay.getCurrentItem()).equals(day)) {
                    day = dayList.get(pvDay.getCurrentItem());
                }

                birth = year + "-" + month + "-" + day;
                blvAgePerson.setRightText(birth);

                // 这里将它转成时间戳
                MyApplication.mLogInDataBean.setBirth(TimeUtils.getLongTime(birth) / 1000 + "");
                mSelfInfoPresenter.setRequestInfo();

                // 修改用户信息
                llBirthday.setVisibility(View.GONE);
                break;
            case R.id.rl_edithead:
                if (llBirthday.getVisibility() == View.VISIBLE || llLoopview.getVisibility() == View.VISIBLE) {
                    ToastUtils.showToast("先编辑其他信息");
                } else {
                    llPicture.setVisibility(View.VISIBLE);
                }
                break;
            case R.id.blv_name_person:
                if (blvNamePerson.getRightText().equals(getString(R.string.please_edit))) {
                    ActivitySwitcher.goEditNameAct(this, "", false);
                } else {
                    ActivitySwitcher.goEditNameAct(this, blvNamePerson.getRightText(), false);
                }
                break;
            case R.id.blv_sex_person:
                initWheel(TYPE_SEX);
                break;
            case R.id.blv_age_person:
                if (llPicture.getVisibility() == View.VISIBLE || llLoopview.getVisibility() == View.VISIBLE) {
                    ToastUtils.showToast("先编辑其他信息");
                } else {
                    llBirthday.setVisibility(View.VISIBLE);
                }
                if (!blvAgePerson.getRightText().equals(getString(R.string.please_edit))) {

                    // 时间戳转换
                    String birthDay = blvAgePerson.getRightText();

                    year = TimeUtils.getYear(birthDay);
                    month = TimeUtils.getMonth(birthDay);
                    day = TimeUtils.getDay(birthDay);
                }
                initBirthday();
                break;
            case R.id.blv_height_person:
                initWheel(TYPE_HEIGHT);
                break;
            case R.id.blv_weight_person:
                initWheel(TYPE_WEIGHT);
                break;
            case R.id.tv_pick_cancel:
                llLoopview.setVisibility(View.GONE);
                blvWeightPerson.setEnabled(true);
                blvHeightPerson.setEnabled(true);
                break;
            case R.id.tv_pick_confirm:
                if (currentType == 1) {
                    String sex = dataList.get(picklerview.getCurrentItem());
                    if (getString(R.string.unit_male).equals(sex)) {
                        // 男
                        MyApplication.mLogInDataBean.setGender("1");
                    } else {
                        MyApplication.mLogInDataBean.setGender("0");
                    }
                    blvSexPerson.setRightText(sex + "");

                } else if (currentType == 2) {
                    blvWeightPerson.setEnabled(true);
                    height = dataList.get(picklerview.getCurrentItem());
                    blvHeightPerson.setRightText(height + getString(R.string.unit_cm));
                    MyApplication.mLogInDataBean.setHeight(height);

                } else if (currentType == 3) {
                    blvHeightPerson.setEnabled(true);
                    weight = dataList.get(picklerview.getCurrentItem());
                    blvWeightPerson.setRightText(weight + getString(R.string.unit_kg));
                    MyApplication.mLogInDataBean.setWeight(weight);
                }

                llLoopview.setVisibility(View.GONE);
                mSelfInfoPresenter.setRequestInfo();
                break;
            case R.id.picture:
                Intent intent = new Intent(SelfInfoActivity.this, ImageChooseActivity_new.class);
                startActivityForResult(intent, PICTURE);
                overridePendingTransition(R.anim.scale_alpha_in, R.anim.scale_alpha_out);
                llPicture.setVisibility(View.GONE);
                break;
            case R.id.camera:
                Intent intentFromCapture = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                // 判断存储卡是否可以用，可用进行存储
                String state = Environment.getExternalStorageState();
                if (state.equals(Environment.MEDIA_MOUNTED)) {
                    File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM);
                    File file = new File(path, CAMERA_IMAGE);
                    intentFromCapture.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
                }
                startActivityForResult(intentFromCapture, CAMERA);
                overridePendingTransition(R.anim.scale_alpha_in, R.anim.scale_alpha_out);
                llPicture.setVisibility(View.GONE);
                break;
            case R.id.select_picture_cancel:
                llPicture.setVisibility(View.GONE);
                break;
            case R.id.iv_back:
                finish();
                break;
            default:
                break;
        }
    }

    //*************************************************选择照片*******************************************//
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode != RESULT_OK) {
            return;
        }
        switch (requestCode) {
            // 相册
            case PICTURE:
                // 从ImageChooseActivity界面中跳转过来的
                String pictureURI = data.getStringExtra(IntentConstants.PICTUREURI);
                File srcFile = new File(pictureURI);
                File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM);
                File targetFile = new File(path, "zhinengneiyi.jpg");
                if (targetFile.exists()) {
                    targetFile.delete();
                }
                File file = DealPictureUtils.copyFile(srcFile, targetFile);
                if (file != null) {
                    CropImageActivity.jump2CropImageActivity(this, file.getPath(), CROPIMAGE);
                }
                break;
            // 相机
            case CAMERA:
                // 判断存储卡是否可以用，可用进行存储
                String state = Environment.getExternalStorageState();
                if (state.equals(Environment.MEDIA_MOUNTED)) {
                    File cameraPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM);
                    File tempFile = new File(cameraPath, CAMERA_IMAGE);
                    CropImageActivity.jump2CropImageActivity(this, tempFile.getPath(), CROPIMAGE);
                }
                break;
            case CROPIMAGE:
                // 剪辑图片完成后
                MyApplication app = MyApplication.getApplication();
                photoBitmap = app.selectBitmap;
                uploadHeadImag();
                break;
            default:
                break;
        }
    }

    private void uploadHeadImag() {
        String path = Constants.SDCARDPATH + MyApplication.mLogInDataBean.getUsername() + ".jpg";

        File file = new File(path);
        file.mkdirs();
        if (file.exists()) {
            file.delete();
        }
        compressBmpToFile(photoBitmap, file);

        // 上传头像
        mSelfInfoPresenter.uploadHeadImage(file);
    }

    public void compressBmpToFile(Bitmap bmp, File file) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        int options = 80;
        bmp.compress(Bitmap.CompressFormat.JPEG, options, baos);
        while (baos.toByteArray().length / 1024 > 300) {
            baos.reset();
            options -= 10;
            bmp.compress(Bitmap.CompressFormat.JPEG, options, baos);
        }
        FileOutputStream fos = null;
        try {
            fos = new FileOutputStream(file);
            fos.write(baos.toByteArray());
            fos.flush();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            CloseUtils.closeQuiety(fos);
        }
    }


    //************************************************生日*************************************************//
    private void setDay() {
        if (Integer.parseInt(year) == currentYear && Integer.parseInt(month) == currentMonth) {
            for (int i = 1; i <= currentDay; i++) {
                dayList.add(String.valueOf(i));
                if (i == Integer.parseInt(day)) {
                    indexDay = i - 1;
                }
            }
        } else {
            if (Integer.parseInt(month) == 2) {
                // 判断是否是闰年
                if (Integer.parseInt(year) % 400 == 0 || (Integer.parseInt(year) % 100 != 0 && Integer.parseInt(year) % 4 == 0)) {
                    dayList.clear();
                    for (int i = 1; i <= 29; i++) {
                        dayList.add(String.valueOf(i));
                        if (i == Integer.parseInt(day)) {
                            indexDay = i - 1;
                        }
                    }
                } else {
                    dayList.clear();
                    for (int i = 1; i <= 28; i++) {
                        dayList.add(String.valueOf(i));
                        if (i == Integer.parseInt(day)) {
                            indexDay = i - 1;
                        }
                    }
                }
            } else if (Integer.parseInt(month) == 4 || Integer.parseInt(month) == 6 || Integer.parseInt(month) == 9 || Integer.parseInt(month) == 11) {
                dayList.clear();
                for (int i = 1; i <= 30; i++) {
                    dayList.add(String.valueOf(i));
                    if (i == Integer.parseInt(day)) {
                        indexDay = i - 1;
                    }
                }
            } else {
                dayList.clear();
                for (int i = 1; i <= 31; i++) {
                    dayList.add(String.valueOf(i));
                    if (i == Integer.parseInt(day)) {
                        indexDay = i - 1;
                    }
                }
            }
        }
    }

    private void setMonth() {
        if (Integer.parseInt(year) == currentYear) {
            indexMonth = 0;
            monthList.clear();
            for (int i = 1; i <= currentMonth; i++) {
                monthList.add(String.valueOf(i));
            }
        } else {
            monthList.clear();
            for (int i = 1; i < 13; i++) {
                monthList.add(String.valueOf(i));
                LogUtils.e(TAG, "=====Month=====" + String.valueOf(i));
                if (i == Integer.parseInt(month)) {
                    indexMonth = i - 1;
                    LogUtils.e(TAG, "-----indexMonth-----" + indexMonth);
                }
            }
        }
    }

    private void initBirthday() {
        yearList = new ArrayList<String>();
        monthList = new ArrayList<String>();
        dayList = new ArrayList<String>();
        for (int i = 1916; i <= currentYear; i++) {
            yearList.add(String.valueOf(i));
            // 判断服务器的年是不是i,如果是则将该下标保存
            if (i == Integer.parseInt(this.year)) {
                indexYear = i - 1916;
            }
        }
        setMonth();
        setDay();
        // 给滚动下标设置数据
        // 设置年月日
        pvYear.setArrayList(yearList);
        pvMonth.setArrayList(monthList);
        pvDay.setArrayList(dayList);

        // 给滚动下标设置默认选中数据的下标
        if (indexYear != -1) {
            pvYear.setCurrentItem(indexYear);
        }
        if (indexMonth != -1) {
            pvMonth.setCurrentItem(indexMonth);
        }
        if (indexDay != -1) {
            pvDay.setCurrentItem(indexDay);
        }

        pvYear.setNotLoop(); // 不循环
        pvMonth.setNotLoop(); // 不循环
        pvDay.setNotLoop(); // 不循环
        pvYear.setMiddleAppleColor();
        pvYear.setMiddleLineVisible(false);
        pvMonth.setMiddleAppleColor();
        pvMonth.setMiddleLineVisible(false);
        pvDay.setMiddleAppleColor();
        pvDay.setMiddleLineVisible(false);
        pvYear.setListener(new LoopListener() {
            @Override
            public void onItemSelect(int item) {
                LogUtils.i("LoopView", String.valueOf(item));
                // text自定义滚动控件中显示选中的内容
                SelfInfoActivity.this.year = yearList.get(item);
                onYearChanged(yearList.get(item));
            }
        });

        pvMonth.setListener(new LoopListener() {
            @Override
            public void onItemSelect(int item) {
                // text自定义滚动控件中显示选中的内容
                SelfInfoActivity.this.month = monthList.get(item);
                onMonthChanged(monthList.get(item));
            }
        });

        pvDay.setListener(new LoopListener() {
            @Override
            public void onItemSelect(int item) {
                // text自定义滚动控件中显示选中的内容
                SelfInfoActivity.this.day = dayList.get(item);
            }
        });
    }

    private void onYearChanged(String year) {
        setMonth();
        pvMonth.setArrayList(monthList);
        pvMonth.setCurrentItem(indexMonth);
        pvMonth.invalidate();

        setDay();
        pvDay.setArrayList(dayList);
        if (indexDay != -1) {
            pvDay.setCurrentItem(indexDay);
        } else {
            pvDay.setCurrentItem(0);
        }
        pvDay.invalidate();
    }

    private void onMonthChanged(String month) {
        setDay();
        pvDay.setArrayList(dayList);
        if (indexDay != -1) {
            pvDay.setCurrentItem(indexDay);
        } else {
            pvDay.setCurrentItem(0);
        }
        pvDay.invalidate();
    }


    //***************************************1:性别 2:身高 3:体重********************************************//

    /**
     * 1:性别 2:身高 3:体重
     *
     * @param typeSex
     */
    private void initWheel(int typeSex) {
        if (llPicture.getVisibility() == View.VISIBLE || llBirthday.getVisibility() == View.VISIBLE) {
            ToastUtils.showToast("先编辑其他信息");
        } else {
            llLoopview.setVisibility(View.VISIBLE);
        }
        currentType = typeSex;
        switch (typeSex) {
            case 1:
                startNub = 0;
                showPickView(1);
                tvBmpUnit.setText("");
                break;
            case 2:
                blvWeightPerson.setEnabled(false);
                startNub = 100;
                endNub = 300;
                firstIndex = 68;
                showPickView(2);
                tvBmpUnit.setText(getString(R.string.unit_cm));
                break;
            case 3:
                blvHeightPerson.setEnabled(false);
                startNub = 20;
                endNub = 200;
                firstIndex = 48;
                showPickView(3);
                tvBmpUnit.setText(getString(R.string.unit_kg));
                break;
        }
    }

    /**
     * 显示选项卡
     */
    private void showPickView(int type) {
        if (dataList.size() > 0) {
            dataList.clear();
        }
        if (type == 1) {
            dataList.add(getString(R.string.unit_male));
            dataList.add(getString(R.string.unit_female));
        } else {
            for (int i = startNub; i < endNub; i++) {
                dataList.add(i + "");
                if (originalData != null && String.valueOf(i).equals(originalData)) {
                    firstIndex = i - startNub;
                }
            }
            //选中当前值
            if (type == 3) {
                if (blvWeightPerson.getRightText().equals(getString(R.string.please_edit))) {
                    firstIndex = 0;
                } else {
                    firstIndex = Integer.parseInt(blvWeightPerson.getRightText().split("kg")[0]) - startNub;
                }
            }
            if (type == 2) {
                if (blvHeightPerson.getRightText().equals(getString(R.string.please_edit))) {
                    firstIndex = 0;
                } else {
                    firstIndex = Integer.parseInt(blvHeightPerson.getRightText().split("cm")[0]) - startNub;
                }
            }
        }
        picklerview.setMiddleAppleColor();
        picklerview.setNotLoop();
        picklerview.setMiddleLineVisible(false);
        picklerview.setArrayList(dataList);
        if (firstIndex != -1) {
            picklerview.setCurrentItem(firstIndex);
        }
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            goBack();
            return false;
        } else {
            return super.onKeyDown(keyCode, event);
        }
    }

    private void goBack() {
        // 更新数据
        finish();
    }

    private void refreshData() {
        Realm mRealm = Realm.getDefaultInstance();
        mRealm.beginTransaction();
        mRealm.copyToRealmOrUpdate(MyApplication.mLogInDataBean);
        mRealm.commitTransaction();
    }


    public void changeUserInfoSucceed() {
        Toast.makeText(this, "修改成功", Toast.LENGTH_SHORT).show();
    }

    public void upLoadHradImageSucceed(String data) {
        ImageLoader.loadNetImageAsCircle(data, ivUserhead);
    }
}
